package com.atguigu.rabbitmq.eight;

import com.atguigu.rabbitmq.util.RabbitmqUtil;
import com.rabbitmq.client.Channel;



/**
 *
 * @author CodingBee
 * @since 2021/6/27/15:49
 * 死信队列：消费者2
 */
public class Consumer02 {
    //死信队列的名称
    public static final String DEAD_QUEUE = "dead_queue";

    public static void main(String[] args) throws Exception {
        //1.获取信道
        Channel channel = RabbitmqUtil.getChannel();
        //接收消息，普通队列
        channel.basicConsume(DEAD_QUEUE, (consumerTag, message) -> {
            System.out.println("Consumer02接收到的消息是：" + new String(message.getBody(), "UTF-8"));
            channel.basicAck(message.getEnvelope().getDeliveryTag(),true);
        }, consumerTag -> {
        });

    }
}
